﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace CustomerUI
{
    /// <summary>
    /// Interaction logic for ChangePassword.xaml
    /// </summary>
    public partial class ChangePassword : Window
    {
        public static DependencyProperty NoticeProperty = DependencyProperty.Register("Notice", typeof(string), typeof(ChangePassword));
        public string Notice
        {
            get { return (string)GetValue(NoticeProperty); }
            set
            {
                SetValue(NoticeProperty, value);
            }
        }
        public ChangePassword()
        {
            InitializeComponent();
            (DataContext as TinyCinema.Bussiness.Login.Customer).Messenger.Register<TinyCinema.Bussiness.Login.Message.ConfirmPasswordNotMatch>(this, (s) =>
            {
                Notice = (App.Current.FindResource("langConfirmPasswordNotMatch") as String);
            });
            (DataContext as TinyCinema.Bussiness.Login.Customer).Messenger.Register<TinyCinema.Bussiness.Login.Message.PasswordChanged>(this, (s) =>
            {
                Notice = (App.Current.FindResource("langPasswordChanged") as String);
            });
            (DataContext as TinyCinema.Bussiness.Login.Customer).Messenger.Register<TinyCinema.Bussiness.Login.Message.PasswordLenghtNotEnough>(this, (s) =>
            {
                Notice = (App.Current.FindResource("langPasswordLenghtNotEnough") as String);
            });
            (DataContext as TinyCinema.Bussiness.Login.Customer).Messenger.Register<TinyCinema.Bussiness.Login.Message.OldPassIncorrect>(this, (s) =>
            {
                Notice = (App.Current.FindResource("langOldPassIncorrect") as String);
            });

        }
        private void Cancel(object sender, RoutedEventArgs e)
        {
            (App.Current.MainWindow as MainWindow).blurEffect.Radius = 0;
            this.Close();
        }

        private void Change(object sender, RoutedEventArgs e)
        {
            var dataContext = DataContext as TinyCinema.Bussiness.Login.Customer;
            dataContext.OldPass = pbxOldPass.Password;
            dataContext.NewPass = pbxNewPass.Password;
            dataContext.ConfirmPass = pbxConfirmPass.Password;
            dataContext.ChangePasswordCommand.Execute(null);
        }
    }
}
